Integration
Implementing the Biometric Capture Session in a View-based UI
This example shows how to integrate the Biometric Capture Session to your project. The Biometric Capture Session extracts a frames collection from the camera preview.
Create View inside ViewController.
After finishing the import of MobaiBiometric inside the project now you can import library inside the swift file .
import MobaiBiometric
In the UI for this example app, we use the following:
Create view
private var mbCaptureSessionView: MBCaptureSessionView
Initialization view whith MBCaptureSessionOptions
public init() {
self.options = MBCaptureSessionOptions()
self.mbCaptureSessionView = MBCaptureSessionView(options: self.options)
}
Setup View Constraints
view.addSubview(takePictureButton)
NSLayoutConstraint.activate([
mbCaptureSessionView.topAnchor.constraint(equalTo: view.topAnchor),
mbCaptureSessionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
mbCaptureSessionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
mbCaptureSessionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
Starts Camera if camera permissions are granted
public override func viewWillAppear(_ animated: Bool) {
mbCaptureSessionView.onStartCapturing()
}
Stop Capturing
public override func viewWillDisappear(_ animated: Bool) {
mbCaptureSessionView.onStopCapturing()
}
Adding delegate and implement the delegate inside View Controller
mbCaptureSessionView.delegate = self
extension ExampleViewController: MBCaptureSessionDelegate {
}
Calling ViewController.
Initialization and calling present of MBCaptureSessionViewController
let viewController = MBCaptureSessionViewController(options: .init())
viewController.delegate = self
self.present(viewController, animated: true, completion: nil)
MBCaptureSessionDelegate
onCompleted is executed for MBCaptureSession class when the capture session is successfully finished
public func onCompleted(result: MBCaptureSessionResult) {
}
onWaiting is executed for DetectedFaceStatus class when the face is not in right circle
public func onWaiting(faceStatus: DetectedFaceStatus) {
}
onStarted is executed when when camera capture started
public func onStarted() {
}
onFailure is executed for MBCaptureSessionService class when the camera can not be
public func onFailure(error: MBCaptureSessionError) {
}
If you have any question please contact .....